import { request } from '@/utils/request'
import { BASE_URL } from '@/utils/constants'
import type { BasePageList } from '@/types/base'
import type { Role } from './types'

const RoleAPI = {
    getRoleList(params: BasePageList<Role>): Promise<BasePageList<Role>> {
        return request.get(`${BASE_URL}/role`, { params })
    },
    createRole(data: Omit<Role, 'id'>): Promise<Role> {
        return request.post(`${BASE_URL}/role`, data)
    },
    getRoleDetail(id: number): Promise<Role> {
        return request.get(`${BASE_URL}/role/${id}`)
    },
    updateRole(id: number, data: Partial<Role>): Promise<Role> {
        return request.put(`${BASE_URL}/role/${id}`, data)
    },
    deleteRole(id: number): Promise<void> {
        return request.delete(`${BASE_URL}/role/${id}`)
    },
    batchDeleteRole(ids: number[]): Promise<void> {
        return request.delete(`${BASE_URL}/role`, { data: { ids } })
    },
    getAllRole(): Promise<Role[]> {
        return request.get(`${BASE_URL}/role/all`)
    }
}

export default RoleAPI